# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Omar Sandoval <osandov AT osandov DOT com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski AT archlinux.org>
# Contributor: Dan McGee <dpmcgee AT gmail.com>

pkgname=sparse
pkgver=0.6.4
pkgrel=4
pkgdesc='Semantic parser for C'
arch=('loong64' 'x86_64')
url='http://sparse.wiki.kernel.org/'
license=('MIT')
depends=(
  'perl'
  'libxml2'
  'sqlite'
)
makedepends=(
  'git'
  'llvm14'
  'gtk3'
)
optdepends=(
  'llvm14-libs: for sparse-llvm'
  'llvm14: for sparsec'
  'gtk3: for test-inspect'
)
_commit='c4706aa764f3ae68258ba60be6325a5662900362'
source=("git+https://git.kernel.org/pub/scm/devel/sparse/sparse.git#commit=$_commit"
        llvm14.patch)
b2sums=('SKIP'
        'd13e86d816c0ec3244ac566057fe1830555263989471d5ecc9f6d52bf4b2b26fc7835bd4f2f0e601a903890b25e61e7fc3ee663f88c43c4fa3cfdca1789a167c')

pkgver() {
  cd sparse

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd sparse

  patch -Np1 -i ../llvm14.patch
}

build() {
  make -C sparse
}

check() {
  make -C sparse check
}

package() {
  cd sparse

  make PREFIX=/usr DESTDIR="$pkgdir" install

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
